<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
<title>${name_china}管理-编辑${name_china}</title>
<%@include file="/common/head.jsp" %>
<link href="<%=request.getContextPath()%>/static/styles/css/main.css" rel="stylesheet">
<script src="<%=request.getContextPath()%>/static/js/jquery.cityselect.js"></script>

</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
            <span class="split"></span>
            <span>编辑${name_china}</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="form" method="post">
    <div class="form-wrapper">
	  <div class="h4 distance-double">
        <span class="h4-title"><i class="icon icon-setting"></i>基本信息</span>
        <span class="h4-border"></span>
      </div>
      
      <div class="form-cont">
	        <input type="hidden" id="userId" name="userId"/> 
	     </div>
      <div class="form-cont">
	        <input type="hidden" id="orderNo" name="orderNo"/> 
	     </div>	     
	     <div class="form-cont">
	        <p class="form-cont-title">收货人姓名</p>
	        <input type="text" id="receiverName" name="receiverName" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[255]']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">手机号</p>
	        <input type="text" id="receiverPhone" name="receiverPhone" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[11]']"/> 
	     </div>
	     
			<div id="city_4" class="form-cont">
				<select class="prov" id="sel1" name="sel1" style="border: solid 1px #eee"></select>
				<select class="city" id="sel2" name="sel2" style="border: solid 1px #eee" disabled="disabled"></select>
				<select class="dist" id="sel3" name="sel3" style="border: solid 1px #eee" disabled="disabled"></select>
			</div>

			<div class="form-cont">
	        <p class="form-cont-title">详细地址</p>
	        <input type="text" id="detail" name="detail" class="summer-input summer-validatebox"  /> 
	     </div>
     
     <div class="form-btn-wrapper" id="funcbar">
        <a class="btn btn-normal" id="saveBtn">保存</a>
        <a class="btn btn-normal" id="backBtn">关闭</a>
    </div>
  </div>
</form>
<script>
    
  var   receiveData,
  		city,
        permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
    	receiveData = ${receiveData};
    	//初始化funcbar
     	/* $('#funcbar').prepend($.funcbar({
            type: 'button',
            data: permission,
            permit: ['${name_english}:saveAddr']
        })); */
   	
        $("#city_4").citySelect({
			prov:"湖南", 
			city:"长沙",
			dist:"岳麓区",
			nodata:"none"
		});
        
     	 $('#form').form({
        	onLoadSuccess:function(data){
               
           }
        }).form('loadDataEdit', {
            data: receiveData
        });
     	 
    	//保存按钮
    	//$('#funcbar').on('click', 'a[data-permit="${name_english}:saveAddr"]', submit);
    	
    	//返回按钮
    	$('#saveBtn').on('click',submit);
    	//返回按钮
    	$('#backBtn, #goBack').on('click',backMain);
    });
    
    
    
    //表单提交
    function submit() {
    	var val1 = $("#sel1").val();
    	var val2 = $("#sel2").val();
    	var val3 = $("#sel3").val();
    	if(val3 == null){
    		city = val1 + val2;
    	}else{
    		city = val1 + val2 +val3;
    	}
         $("#form").form({
        	 buttons : ['#saveBtn'],
             ajax: {
                 url: CONST_URL.EDIT+"?city="+city+""
             },
             onSubmitSuccess: function (data) {
            	 $.stip({
   	                type:'ok',//显示类型 有info、 ok、 danger
   	                text: '保存成功！',
   	                onBeforeHide: function () {
   	                	if( typeof window.opener == 'object' && typeof window.opener.closeWindow=='function') {
   	                     window.opener.closeWindow(window, true); //不刷新 false
   	                 } 
   	                }
            	 });
              }
         }).form("submit");
    }
    
    //返回主页面
    function backMain() {
    	window.location.href = CONST_URL.INIT_MAIN;
    }
    
    //请求url
    var CONST_URL = {
    	INIT_MAIN: basePath + "${common_url}init",
       	EDIT: basePath + "${common_url}saveAddr"
    };
    
</script>
</body>
</html>